/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUInemeanshop;

import components.NLabel;
import components.NPanel;
import java.awt.GridLayout;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import nemeanshop.NemeanShop;

/**
 *
 * @author havardaxelsen
 */
public class GUISettings extends NPanel{
    
    
    private NLabel utlogg = new NLabel("Minutter for automatisk utlogging:");
    static final int FPS_MIN = 1;
    static final int FPS_MAX = 10;
    static final int FPS_INIT = 5;    //initial frames per second

    private JSlider antmin = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, FPS_INIT);
    private GUIContent gc; 
    private SlideListener listener = new SlideListener(); 
    public GUISettings(GUIContent gc){
        antmin.setFocusable(false);
        this.setLayout(new GridLayout(1,2));
        this.gc = gc;
        add(utlogg);
        antmin.setMajorTickSpacing(3);
        antmin.setMinorTickSpacing(1);
        antmin.setPaintTicks(true);
        antmin.setPaintLabels(true);
        antmin.addChangeListener(listener);
        antmin.setValue(gc.getLogoutTime());
        antmin.setSnapToTicks(true);
        add(this.antmin);
        
    }
    
    private class SlideListener implements ChangeListener {

        @Override
        public void stateChanged(ChangeEvent ce) {
            
            JSlider source = (JSlider)ce.getSource();
            
            if (!source.getValueIsAdjusting()) {
                int fps = (int)source.getValue();
                
                gc.updateLogoutTime(fps);
        }
    
}
}
}
